package com.hospital.common.enums.schedule.module;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;

/**
 * 小时段枚举
 * <br>
 * 0: 08:00-09:00
 * <br>
 * 1: 09:00-10:00
 * <br>
 * 2: 10:00-11:00
 * <br>
 * 3: 14:00-15:00
 * <br>
 * 4: 15:00-16:00
 * <br>
 * 5: 16:00-17:00
 * @author yhn
 * @version 1.0
 */
public enum HourSlotType {
    AM1(0,"08:00-09:00"),
    AM2(1,"09:00-10:00"),
    AM3(2,"10:00-11:00"),
    PM1(3,"14:00-15:00"),
    PM2(4,"15:00-16:00"),
    PM3(5,"16:00-17:00");
    public final Integer value;
    public final String time;
    HourSlotType(Integer value, String time) {
        this.value = value;
        this.time = time;
    }

    /**
     * 根据数据库内的字段传入来对应时间段枚举
     * @param code
     * @return
     */
    public static String fromCode(Integer code) {
        for (HourSlotType slot : values()) {
            if (slot.value == code) {
                return slot.time;
            }
        }
        throw new IllegalArgumentException("无效的时间段编码：" + code);
    }

}
